package cn.lwj.webService.base;

import java.io.Serializable;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;

public interface DaoTool {
	public <T> void save(T t);
	
	public <T> void saveOrUpdate(T t);
	
	public <T> void saveLog(T t);
	
	public <T> void saveOrUpdateLog(T t);

	public <T> void merge(T t);

	public <T> void delete(T t);
	
	public <T> void deleteLog(T t);

	public <T> void delete(Class<T> entityClass, String id);
	
	public void deleteObject(Object model);

	public <T> void update(T t);

	public <T, PK extends Serializable> T get(Class<T> entityClass, PK id);

	public <T> List<T> findAll(String hql, Class<T> entityClass);
	
	public <T> List<T> findAllByOpenSession(String hql, Class<T> entityClass);

	public <T> List<T> findAll(String hql, Class<T> entityClass, Object param);

	public <T> List<T> findAll(String hql, Class<T> entityClass, Object[] params);
	
	public <T> List<T> findAllByOpenSession(String hql, Class<T> entityClass, Object[] params);

	public <T> List<T> findByPage(final String hql, final Class<T> entityClass,
			final int firstResult, final int maxResult);

	public <T> List<T> findByPage(final String hql, final Class<T> entityClass,
			final Object param, final int firstResult, final int maxResult);

	public <T> List<T> findByPage(final String hql, final Class<T> entityClass,
			final Object[] params, final int firstResult, final int maxResult);

	public SQLQuery createSQLQuery(String sql);

	public Query createHQLQuery(String hql);
	
	public <T>List createHQLQueryListByOpenSeesion(String hql);
	
	public <T> List<T> findSQLList(String sql,Class entityClass,int page,int pageSize, Object... params);
	
	public <T> List<T> findList(String hql, int page,int pageSize,Object ...params);
	
	public <T> List<T> findList(String hql,Object ...params);
	
	public List findSQLList(String sql,Class entityClass,Object ...params);
	
	public Session getCurrentSession();
	
	public Session getOpenSession();

	public <T> void deleteByOpenSeesion(T t);

	public <T> void saveOrUpdateByOpenSeesion(T t);
}
